<extend name="common"/>
<block name="title">{$qqrow.qq}单项好友检测-{:C('web_name')}</block>
<block name="head">
<script type="text/javascript">
function SelectAll(chkAll) {
	var items = $('.uins');
	for (i = 0; i < items.length; i++) {
		if (items[i].id.indexOf("uins") != -1) {
			if (items[i].type == "checkbox") {
				items[i].checked = chkAll.checked;
			}
		}
	}
}
$(document).ready(function(){
	$('#startcheck').click(function(){
		self=$(this);
		if (self.attr("data-lock") === "true") return;
			else self.attr("data-lock", "true");
		self.html('检测中<img src="/Style/images/load.gif" style="height: 15px;">');
		var url="/api/dx.php";
		klmz.postData(url,'uin={$qqrow.qq}&sid={$qqrow.sid}', function(d) {
			if(d.code ==0){
				self.html('这一组检测完成，3秒后进行下一组，请稍等！');
				$('#count').html(d.count);
				$('#dxcount').html(d.dxcount);
				if(d.dxrow){
					$.each(d.dxrow, function(i, item){
						$("#content").append('<tr><td><input name="uins" type="checkbox" class="uins" id="uins" value="'+item.uin+'">'+item.uin+'</td><td>'+item.nick+'</td><td>'+item.remark+'</td><td align="center"><button class="btn btn-large btn-block qqdel del'+item.uin+'" uin="'+item.uin+'">删除</button></td></tr>'); 
					});  
				}
				if(d.finish==1){
					$('#load').html('好友全部检测完毕！');
				}else{
					 setTimeout(function () {
						$('#startcheck').click()
					 }, 3000);
					//$('#startcheck').click();
				}
			}else{
				alert(d.msg);
			}
		});
		self.attr("data-lock", "false");
	});
	$(document).on("click",".qqdel",function(){
		var checkself=$(this),
			touin=checkself.attr('uin');
		checkself.html('<Iframe src="/api/qqdel.php?uin={$qqrow.qq}&skey={$qqrow.skey}&touin='+touin+'" width="50px" height="30px" scrolling="no" frameborder="0"></iframe>');
	});
	$('.alldel').click(function(){
		var uin;
		$("input[name=uins]").each(function(){
			if($(this)[0].checked){
				uin=$(this).val();
				$('.del'+uin).html('<Iframe src="/api/qqdel.php?uin={$qqrow.qq}&skey={$qqrow.skey}&touin='+uin+'" width="50px" height="30px" scrolling="no" frameborder="0"></iframe>');
			}
		});
	});
});
</script>
</block>
<block name="page">
<div class="row">
	<div class="col-xs-12">
		<ol class="breadcrumb">
			<li><a href="/"><span class="hidden-xs">{:C('web_name')}</span><span class="hidden-md hidden-lg">首页</span></a></li>
			<li><a href="{:U('user')}">用户中心</a></li>
			<li><a href="{:U('qq','qid='.$qqrow['qid'])}">{$qqrow.qq}</a></li>
			<li class="active">单项好友检测</li>
		</ol>
	</div>
</div>
<div class="row">
	<div class="panel-group  col-xs-12" id="gpnames">
		<div class="panel panel-info">
			<div class="list-group-item">
				<button class="btn btn-success btn-block" id="startcheck">开始单项检测</button>
			</div>
			<div class="panel-heading">
				<div class="panel-title" align=center>总共{:count($arr)}个好友,已检测<span id="count">{:count($_SESSION["o".$qqrow[qq]])}</span>个，单项<span id="dxcount">{:count($dxrow)}</span>个！</div>
			</div>
			<div class="panel-collapse collapse in">
				<div class="panel-body">
					<table class="table  table-bordered" style="table-layout: fixed;">
					<tbody id="content">
					<tr><td style="width:120px;" align="center"><input type="checkbox" onclick="SelectGpAll({$row.gpid},this)"/>QQ号</td><td class="mzwidthtd" align="center"">昵称</td><td class="mzwidthtd" align="center">备注</td><td align="center">删除</td></tr>
					<volist name="dxrow" id="row" key="k">
					<if condition='stripos($json,"uin\":".$row[uin])'>
						<tr><td><input name="uins" type="checkbox" class="uins" id="uins" value="{$row['uin']}">{$row['uin']}</td><td class="mztd">{$row['nick']}</td><td class="mztd">{$row['remark']}</td><td align="center"><button class="btn btn-large btn-block qqdel del{$row['uin']}" uin="{$row['uin']}">删除</button></td></tr>
					<else/>
						<?php unset($_SESSION['klsf_dxrow']["$qqrow[qq]"][$k-1]);?>
					</if>
					</volist>
					</tbody>
					</table>
				</div>
			</div>
		</div>
		<div class="panel panel-warning">
			<div class="panel-heading">
				<div class="panel-title">
					<div class="input-group">
						<div class="input-group-addon btn">全选<input type="checkbox" onclick="SelectAll(this)" /></div>
						<div class="input-group-addon btn alldel">删除选择好友</div>
						<a href="{:U('dxjc','do=clear')}" class="input-group-addon btn">清空检测结果</a>
					</div>
				</div>
			</div>
		</div>
	</div>
	
</div>
</block>